package com.www.applyword.ui.my;

import android.widget.ImageView;
import android.widget.TextView;

import com.allen.library.SuperTextView;
import com.www.applyword.Constants.Constants;
import com.www.applyword.R;
import com.www.applyword.base.BaseActivity;
import com.www.applyword.bean.WXPayBean2;
import com.www.applyword.http.CallBack;
import com.www.applyword.http.HttpClient;
import com.www.applyword.utils.ImageUtil;
import com.www.applyword.utils.SPUtil;
import com.www.applyword.utils.Utils;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;
import de.hdodenhof.circleimageview.CircleImageView;

/**
 * author : huang
 * date   : 2019/11/15 0015 16:22
 * version: 1.0
 *
 * @author Administrator
 */
public class CodeActivity extends BaseActivity {
    @BindView(R.id.st_company)
    SuperTextView stCompany;
    @BindView(R.id.iv_code)
    ImageView ivCode;
    @BindView(R.id.tv_my_photo)
    CircleImageView tvMyPhoto;
    @BindView(R.id.tv_my_name)
    TextView tvMyName;
    @BindView(R.id.tv_my_phone)
    TextView tvMyPhone;

    @Override
    protected void loadViewLayout() {
        setContentView(R.layout.code_activity);
        setTitle("我的邀请码");

    }

    @Override
    protected void loadData() {
        Map<String, Object> params = new HashMap<>();
        params.put("UserID", SPUtil.getString(Constants.USERID));
        HttpClient.get(CodeActivity.this, Constants.GETMYACTIVECODE, params, new CallBack<WXPayBean2>() {
            @Override
            public void onSuccess(WXPayBean2 result) {
                if (result.Status == 1) {
                    tvMyPhone.setText(result.Result.ActiveCode);
                    ImageUtil.setImage(tvMyPhoto, SPUtil.getString(Constants.PHOTO));
                    //  String url =   Utils.bitmaptoString(Utils.stringtoBitmap(result.ActiveCodeImg));
                    ivCode.setImageBitmap(Utils.base64ToBitmap(result.Result.ActiveCodeImg));
                    //  ImageUtil.setImage(ivCode,url);
                }
            }
        });
    }
}
